package wiinf;

/**
 *
 * @author Randy van Heijst
 */
public class oplToevoegen extends javax.swing.JPanel {
    private serverViewModel model;

    /**
     * Aanmaken nieuwe panel voor opleidingen toevoegen
     *
     * @param model De JFrame waar de panel in komt
     */
    public oplToevoegen(serverViewModel model) {
        this.model=model;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ToplNaam = new javax.swing.JTextField();
        ToplLocatie = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ToplInfo = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        CoplAfdeling = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        BoplOpslaan = new javax.swing.JButton();

        jLabel1.setText("Naam opleiding:");

        jLabel2.setText("Afdeling:");

        ToplInfo.setColumns(20);
        ToplInfo.setRows(5);
        jScrollPane1.setViewportView(ToplInfo);

        jLabel3.setText("Locatie opleiding:");

        CoplAfdeling.setModel(new javax.swing.DefaultComboBoxModel(new String[] {} ));
        model.setAfdelingBox(CoplAfdeling);

        jLabel4.setText("Informatie opleiding:");

        BoplOpslaan.setText("Opslaan");
        BoplOpslaan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BoplOpslaanActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(147, 147, 147)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(CoplAfdeling, 0, 161, Short.MAX_VALUE)
                                    .addComponent(ToplLocatie, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                                    .addComponent(ToplNaam, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(354, Short.MAX_VALUE)
                        .addComponent(BoplOpslaan)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ToplNaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CoplAfdeling, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ToplLocatie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(16, 16, 16)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BoplOpslaan)
                .addGap(56, 56, 56))
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Actionlistener horende bij de opslaan button
     *
     * @param evt Action event
     */
    private void BoplOpslaanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BoplOpslaanActionPerformed
        String naam = ToplNaam.getText();
        String afdeling = CoplAfdeling.getSelectedItem().toString();
        String locatie = ToplLocatie.getText();
        String info = ToplInfo.getText();
          
        String[] data={naam,locatie,info};
        model.server.createOpleiding(afdeling,naam,data);
    }//GEN-LAST:event_BoplOpslaanActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BoplOpslaan;
    private javax.swing.JComboBox CoplAfdeling;
    private javax.swing.JTextArea ToplInfo;
    private javax.swing.JTextField ToplLocatie;
    private javax.swing.JTextField ToplNaam;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
